-
Notifications
You must be signed in to change notification settings - Fork 10.3k
etcdctl: add fake client for UT #20270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: hwdef The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @hwdef. Thanks for your PR. I'm waiting for a etcd-io member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/ok-to-test |
|
|
||
| // KV | ||
|
|
||
| type kvStub struct{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to think about how to pass in the mock response.
Like a fake dict of kvs, a list of alarms.
Can you try to use the fakeclient to test alarm_command as an example of how it should work?
Codecov Report❌ Patch coverage is Additional details and impacted files
... and 28 files with indirect coverage changes @@ Coverage Diff @@
## main #20270 +/- ##
==========================================
+ Coverage 68.48% 68.84% +0.35%
==========================================
Files 429 431 +2
Lines 35242 35308 +66
==========================================
+ Hits 24135 24307 +172
+ Misses 9723 9568 -155
- Partials 1384 1433 +49 Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
6f0f3ff to
e050fdb
Compare
34dcb55 to
ca8b054
Compare
ca8b054 to
abab404
Compare
abab404 to
4cd9111
Compare
4d76620 to
21d330d
Compare
0eb3dff to
364b200
Compare
|
@siyuanfoundation @Elbehery @serathius |
|
Overall this approach works. Another option would be refactor all the functions like @ahrtr would really appreciate your input. Thanks! |
39b15be to
4bb7e7b
Compare
|
/retest |
| func newTestRoot() *cobra.Command { | ||
| root := &cobra.Command{Use: "etcdctl"} | ||
| root.AddGroup(NewKVGroup(), NewClusterMaintenanceGroup(), NewConcurrencyGroup(), NewAuthenticationGroup(), NewUtilityGroup()) | ||
| root.PersistentFlags().StringSlice("endpoints", []string{"127.0.0.1:2379"}, "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
abstract to a function shared with init()
| "go.etcd.io/etcd/etcdctl/v3/ctlv3/command/fakeclient" | ||
| ) | ||
|
|
||
| func withStdoutCapture(t *testing.T, fn func()) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move this and setupFake to a separate file like test_utils.go
6634073 to
983a7ad
Compare
|
|
||
| // GlobalFlags are flags that defined globally | ||
| // and are inherited to all sub-commands. | ||
| type GlobalFlags struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems this struct is not very useful to begin with. How about moving the refactor to a separate PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check unused flag.
2ad067e to
4e2be22
Compare
|
/retest |
Signed-off-by: hwdef <[email protected]>
4e2be22 to
88c6f10
Compare
|
@hwdef: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Part of: #20171
/cc @siyuanfoundation @Elbehery